function Food(ele) {
    this.ele = ele
    this.len = 20
    this.foodObj = null
    this.foodX = 0
    this.foodY = 0
}

Food.prototype.create = function() {
    let divObj = document.createElement('div')
    divObj.style.width = this.len + 'px'
    divObj.style.height = this.len + 'px'
    divObj.style.background = 'url(./imgs/food.png)'
    divObj.style.position = 'absolute'
    this.foodObj = divObj
    this.ele.appendChild(divObj)
    this.move()
}

Food.prototype.move = function() {

    let foodXMaxNum = this.ele.clientWidth / this.len - 1
    let foodYMaxNum = this.ele.clientHeight / this.len - 1
    this.foodX = Math.floor(Math.random() * (foodXMaxNum-0+1)+0) * this.len
    this.foodY = Math.floor(Math.random() * (foodYMaxNum-0+1)+0) * this.len

    console.log(this.foodX)
    console.log(this.foodY)
    this.foodObj.style.left = this.foodX + 'px'
    this.foodObj.style.top = this.foodY + 'px'
}
